package LW.org.daoImple;

import LW.org.dao.BaseDao;
import LW.org.dao.roomDao;
import LW.org.model.Room;
import LW.org.model.RoomUse;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
import org.hibernate.loader.plan.spi.QuerySpaceUidNotRegisteredException;

import java.util.Date;
import java.util.List;

@SuppressWarnings("unchecked")
public class roomDaoImple extends BaseDao implements roomDao {

    @Override
    public Room select(int room_id) {
        Session session = getSession();
        Query query = session.createQuery("from Room r where r.id=:id");
        query.setParameter("id",room_id);
        List<Room> templateOne = query.list();
        if(templateOne.size()>0){
            return templateOne.get(0);
        }
        return null;
    }

    @Override
    public List<Room> select_all() {
        Session session = getSession();
        Query query = session.createQuery("from Room");
        List<Room> allRoom = query.list();
        System.out.println("room total num : "+allRoom.size());
        if(allRoom!=null)
        {
            return allRoom;
        }
        return null;
    }

    @Override
    public Boolean insert_one(Room newRoom) {
        return null;
    }

    @Override
    public Boolean delete_one(int room_id) {
        return null;
    }

    @Override
    public Boolean update_one(Room newRoom) {
        return null;
    }
}
